

<!--
 * @Description: 直接荧光屏
 * 
 * Copyright (c) 2023 by cgl/微盛信息产业有限公司, All Rights Reserved. 
-->
<template>
  <div class="content">

      <div class="tip-30">
        <el-checkbox v-model="form.notHave" @change="handleChangeInfo">非直接荧光屏透视设备，不检测此项</el-checkbox>
      </div>
      <div id="table3-1">
				<div class="innertitle">
					1.直接荧光屏透视灵敏度
				</div>
        <div class="tip-30">
          <i>剂量校准因子：$C_{f}$ = <el-input v-model="form1.calibrationFactorDose" style="width: 100px;"/> 亮度校准因子: $C_{f}$=<el-input v-model="form1.calibrationFactorBrightness" style="width: 100px;"/></i>
        </div>

				<table border="1" cellspacing="0" cellpadding="0" align="center" style="width: 100%;">
					<tr>
						<td>管电压<br>(kV)</td>
						<td>管电流<br>(kV)</td>
						<td colspan="4">读数</td>
						<td>平均值</td>
						<td>校准值</td>
						<td><i>$B((cd/m^2)/(mGy/min))$</i></td>
					</tr>
          <tr>
            <td rowspan="2">60</td>
            <td rowspan="2">3</td>
            <td>b</td>
            <td><el-input v-model="form1.readoutValue_1_1"/></td>
            <td><el-input v-model="form1.readoutValue_1_2"/></td>
            <td><el-input v-model="form1.readoutValue_1_3"/></td>
            <td><el-input v-model="form1.average_1"/></td>
            <td><el-input v-model="form1.calibrationValue_1"/></td>
            <td rowspan="2"><el-input v-model="form1.sensitivity"/></td>
          </tr>
          <tr>
            <td><i>$\overset{·}{K}$</i></td>
            <td><el-input v-model="form1.readoutValue_2_1"/></td>
            <td><el-input v-model="form1.readoutValue_2_2"/></td>
            <td><el-input v-model="form1.readoutValue_2_3"/></td>
            <td><el-input v-model="form1.average_2"/></td>
            <td><el-input v-model="form1.calibrationValue_2"/></td>
          </tr>
					
				</table>

        <div class="tip-30">
          标准值=读数x校准因子，<i>$B = b/\overset{·}{K}$</i>
        </div>
			</div>

      <div id="table3-2">
        <div class="innertitle">
					2.最大照射野与直接荧光屏尺寸相同的台屏距
				</div>
        <div class="tip-30">
          照射设置到最大，当最大照射野等于荧光屏大小时，床面板到荧光屏后面板的距离: <el-input v-model="form.screenSpacing" @change="handleChangeInfo" style="width: 100px;"/>mm。
        </div>
      </div>
  </div>
</template>

<script>
import {getInfoById02, saveInfo02, sensitivity} from '@/api/testItem/itemTS02'

export default {
  name: "testItem02",
  data() {
    return {
      fovList: [
        {
          id: 1,
          label: 'mm',
          value: 1
        },
      ],
      readoutList: [
        {
          id: 1,
          label: 'uGy/s',
          value: 1
        },
        {
          id: 2,
          label: 'uGy/min',
          value: 2
        },
        {
          id: 3,
          label: 'mGy/min',
          value: 3
        },
      ],
      fieldSizeList: [
        {
          id: 1,
          label: 'mm',
          value: 1
        },
      ],
      // tab切换通用数据
			form: {},
			// 表单-1.透视受检者入射体表空气比释动能率典型值
			form1: {

			},
			// 表单-2、透视受检者入射体表空气比释动能率最大值
			form2: {

			},
			itemsId: null,
    };
  },
  props: {
		// tab栏
    activeNameEquipment: {
			type: String,
      default: "0",
    },
		// 基本信息数据
    basicForm: {
			type: Object,
      default: () => {
				return {}
			},
    },
  },
  watch: {
    activeNameEquipment: {
      handler(val) {
		    let _this = this;
				this.$nextTick(()=>{
          // 02-直接荧光屏透视设备专用检测项目
          // 获取详情
          getInfoById02(this.basicForm.resultId).then(response => {
            let {notHave, screenSpacing, itemsId, resultId} = response.data
            this.itemsId =  response.data?.itemsId;
            // 1.探测器剂量指示（DDI）
            this.form1 =  response.data?.sensitivity || {};

            this.form = {itemsId, resultId, notHave, screenSpacing}
          }).catch((response) => {
            console.log("catch-->getInfoById06", response);
            this.$emit("loadingchange", true);
          });
          // 绑定请求
          let itemsLength = 1;
          for (let index = 0; index < itemsLength; index++) {
            
            let tableInputs = document.getElementById(`table3-${index + 1}`).getElementsByTagName("input");
            for (let i = 0; i < tableInputs.length; i++) {
							this.bind(tableInputs[i], () => {
								this.submitTestForm(index + 1)
							})
              // let elSelect = this.elHaveComponent(tableInputs[i]) // 获取Component
              // elSelect.$on('change', function(){
              //   _this.validate(tableInputs[i])
              //   _this.submitTestForm(index + 1)
              // })
              
            }
            
          }
				})
      },
      deep: true,
      immediate: true
    },
  },
	// updated() {
	// 	console.log("updated--this.basicInfo", this.basicInfo);
	// },
	// destroyed() {
	// 	console.log("destroyed--this.basicInfo", this.basicInfo);
	// },
  methods: {
    // 直接荧光屏透视设备专用检测项目-02
		submitTestForm(index) {
			console.log("提交检测项", index);
			this.$emit("loadingchange", true); /* 说明绑定成功 */
			this[`form${index}`].itemsId = this.itemsId;
			switch (index) {
				// 1.DAS动态范围。DAS对比灵敏度 伪影
				case 1:
          sensitivity(this.form1).then((response) => {
						// this.$modal.msgSuccess("保存成功");
						response.data ? this.form1 = response.data : "";
						this.$emit("loadingchange", false);
					})
        	break;
			}
		},
    async handleChangeInfo() {
      console.log('11111111', this.activeNameEquipment)
      await saveInfo02(this.form)
    },
  },
};
</script>

<style lang="scss" scoped>
@import '../content.scss';
</style>